#ifndef __MAIN_FORM
#define __MAIN_FORM

#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <Buttons.hpp>
#include <ExtCtrls.hpp>
#include <ComCtrls.hpp>
#include <ImgList.hpp>

#include "BkList.h"
#include "HCFGStorage.h"
#include "TB97Ctls.hpp"
#include <Dialogs.hpp>
#include <Menus.hpp>

class TMainForm : public TForm {
  __published:
        TPanel *Panel1;
        TLabel *Label1;
        TComboBox *cbPort;
        TToolbarButton97 *btnConnect;
        TGroupBox *GroupBox1;
        TPanel *Panel2;
        TToolbarButton97 *btnRefreshInfo;
        TLabel *Label2;
        TLabel *txtName;
        TLabel *Label4;
        TLabel *txtVer;
        TLabel *Label6;
        TLabel *txtFirm;
        TLabel *Label8;
        TLabel *txtUser;
        TLabel *Label10;
        TLabel *txtWeight;
        TLabel *Label12;
        TLabel *txtHeight;
        TLabel *Label14;
        TLabel *txtBirth;
        TLabel *Label16;
        TLabel *txtData;
        TGroupBox *GroupBox2;
        TPanel *Panel3;
        TToolbarButton97 *btnRefreshWP;
        THeaderControl *hdrWP;
        HBkList *listWP;
        TGroupBox *GroupBox3;
        TPanel *Panel4;
        TToolbarButton97 *btnRefreshTracks;
        THeaderControl *hdrTracks;
        HBkList *listTracks;
        HCfgStorage *cfg;
        TImageList *images;
        TToolbarButton97 *btnWPEdit;
        TToolbarButton97 *btnWPDel;
        TToolbarButton97 *btnWPImport;
        TToolbarButton97 *btnWPExport;
        TPopupMenu *popupWPOpen;
        TPopupMenu *popupWPSave;
        TToolbarButton97 *btnWPUpdate;
        TMenuItem *mnuWPAdd;
        TMenuItem *mnuWPReplace;
        TOpenDialog *open;
        TSaveDialog *save;
        TPopupMenu *popupTROpen;
        TPopupMenu *popupTRSave;
        TSplitter *Splitter1;
        TSplitter *Splitter2;
        TGroupBox *GroupBox4;
        TPanel *Panel5;
        TToolbarButton97 *btnTRImport;
        TToolbarButton97 *btnTRExport;
        THeaderControl *hdrPoints;
        HBkList *listPoints;
        TToolbarButton97 *btnTRDownload;
        TToolbarButton97 *btnPTEdit;
        TToolbarButton97 *btnPTDel;
        TStatusBar *stPT;
        TLabel *Label3;
        TComboBox *cbSpeed;
        TLabel *Label5;
        TLabel *Label7;
        TEdit *Edit1;
        TUpDown *btnCharTimeout;
        TLabel *Label9;
        void __fastcall btnConnectClick(TObject *Sender);
        void __fastcall btnRefreshInfoClick(TObject *Sender);
        void __fastcall btnRefreshWPClick(TObject *Sender);
        void __fastcall btnRefreshTracksClick(TObject *Sender);
        bool __fastcall listWPDrawItemSection(TObject *Sender, TCanvas *dc,
          int Index, THeaderSection *Section, const MyRect &Rect,
          const TOwnerDrawState &State);
        bool __fastcall listTracksDrawItemSection(TObject *Sender,
          TCanvas *dc, int Index, THeaderSection *Section,
          const MyRect &Rect, const TOwnerDrawState &State);
        void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
        void __fastcall btnWPEditClick(TObject *Sender);
        void __fastcall btnWPDelClick(TObject *Sender);
        void __fastcall btnWPUpdateClick(TObject *Sender);
        void __fastcall btnTRDownloadClick(TObject *Sender);
        bool __fastcall listPointsDrawItemSection(TObject *Sender,
          TCanvas *dc, int Index, THeaderSection *Section,
          const MyRect &Rect, const TOwnerDrawState &State);
        void __fastcall idRefreshTRIntf(TObject *Sender);
        void __fastcall idRefreshWPIntf(TObject *Sender);
        void __fastcall idRefreshPTIntf(TObject *Sender);
        void __fastcall btnPTDelClick(TObject *Sender);
  private:
    GH615 Device;
    bool  LastErr;

  public:
    __fastcall TMainForm(TComponent* Owner);

    void SaveCfg( void );
    void LoadCfg( void );

    void SetInvalid( void );
    void FillInfo( bool valid );
    void FillWP( bool valid );
    void FillTracks( bool valid );
    void FillPoints( bool valid );

    void __fastcall idWPAdd( TObject *Sender );
    void __fastcall idWPReplace( TObject *Sender );
    void __fastcall idWPSave( TObject *Sender );

    void __fastcall idTRLoad( TObject *Sender );
    void __fastcall idTRSave( TObject *Sender );

    bool __fastcall idProgress( GH615 *Sender, int Pc );
};

#endif
